package org.jeecg.modules.demo.wuyou.api;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import com.alibaba.fastjson.JSONObject;
import jakarta.servlet.http.HttpServletRequest;
import org.jeecg.common.api.vo.Result;

import org.jeecg.config.shiro.IgnoreAuth;
import org.jeecg.modules.demo.wuyou.entity.Sitemap;
import org.jeecg.modules.demo.wuyou.service.ISitemapService;

import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

 /**

 * @Description: sitemap
 * @Author: ONE
 * @Date:   2024-09-30
 * @Version: V1.0
 */
//@Tag="sitemap-APi服务")
@RestController()
public class SitemapControllerApi extends JeecgController<Sitemap, ISitemapService> {
	@Autowired
	private ISitemapService sitemapService;


	 @GetMapping(value = "/sitemap.xml", produces = "application/xml")
	 @IgnoreAuth
	 public String getSitemap() {
		 System.out.println("sitemapService = " + sitemapService);
		 return sitemapService.getSitemap();
	 }

	@GetMapping(value = "/footTemplate")
	@IgnoreAuth
	@ResponseBody
	 public Result<HashMap<String, List<Map<String, Object>>>> footTemplate() {
		return Result.OK(sitemapService.getSelectMap());

	 }

	 @PostMapping(value = "/scrmUpdata")
	 @IgnoreAuth
	 @ResponseBody
	 public Result<String> scrmUpdata(@RequestBody JSONObject jsonData) {
		  jsonData.put("appKey", "6497d6fd67d75872");
		  jsonData.put("sign", "ZmIzMDllOTZiOWY4NjVlMzkwNGYwMmRkYmFlMWFiNzA3MjhhZWZlYmY1ZTA3NzIyZGJjMGE0MTZkNzVjMDNjMw==");
		  jsonData.put("worksheetId","gwkh" );
		  jsonData.put("triggerWorkflow",true);
		 Boolean httpStatus = sitemapService.getHttpStatus(jsonData.toJSONString());
		 if (!httpStatus){
			 return Result.error("请求失败");
		 }
		 return Result.OK("提交成功");

	 }
	 @RequestMapping(value = "/web/v1/FileImages",name = "上传图片路径")
	 @ResponseBody
	 @IgnoreAuth
	 public  Map<String, String> FileImages(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception {
//		 String s = FileDownloadUtils.updateFileImages(file, request);
		 HashMap<String, String> stringStringHashMap = new HashMap<>();
		 stringStringHashMap.put("url","s");
		 return stringStringHashMap;
	 }




}
